import { Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn,  } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";
import { CharacterEntity } from "./character.entity";

@Entity("character_detailed_attributes")
@ManualTimestamp()
export class CharacterDetailedAttributeEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column("int", { name: "characterId" })
  characterId!: number;

  @Column("int", { default: 0, comment: "抗物理" })
  k_wl!: number;

  @Column("int", { default: 0, comment: "抗围困" })
  k_wei!: number;

  @Column("int", { default: 0, comment: "抗封印" })
  k_feng!: number;

  @Column("int", { default: 0, comment: "抗风系" })
  k_fa!: number;

  @Column("int", { default: 0, comment: "抗毒系" })
  k_du!: number;

  @Column("int", { default: 0, comment: "抗玄系" })
  k_xi!: number;

  @Column("int", { default: 0, comment: "抗混乱" })
  k_luan!: number;

  @Column("int", { default: 0, comment: "抗妖系" })
  k_yao!: number;

  @Column("int", { default: 0, comment: "抗雷系" })
  k_ll!: number;

  @Column("int", { default: 0, comment: "暴击率" })
  r_bj!: number;

  @Column("int", { default: 0, comment: "反击率" })
  r_fj!: number;

  @Column("int", { default: 0, comment: "反震率" })
  r_fz!: number;

  @Column("int", { default: 0, comment: "躲避率" })
  r_hb!: number;

  @Column("int", { default: 0, comment: "法术暴击率" })
  r_mf!: number;

  @Column("int", { default: 0, comment: "命中率" })
  r_mz!: number;

  @Column("int", { default: 0, comment: "致命率" })
  r_zm!: number;

  @Column("varchar", {
    length: 8,
    default: "一",
    comment: "速度字符串(一,二,三,四,五,六,七,八,九)",
  })
  speedStr!: string;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date;

  // 关联关系
  @OneToOne(() => CharacterEntity, (character) => character.detailedAttributes)
  @JoinColumn({ name: "characterId" })
  character!: CharacterEntity;
}
